<?php if (!defined('THINK_PATH')) exit();?><table class="table table-hover">
    <thead>
        <tr>
            <th>规格</th>
            <th>属性值</th>
            <th>附加价格</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
    <?php if(is_array($goodsAttrData)): $i = 0; $__LIST__ = $goodsAttrData;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$gad): $mod = ($i % 2 );++$i;?><tr>
            <td><?php echo ($gad['taname']); ?></td>
            <td>
                <select name="spec[<?php echo ($gad['taid']); ?>][]" id="">
                    <?php if(is_array($gad["tavalue"])): $i = 0; $__LIST__ = $gad["tavalue"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><option value="<?php echo ($v); ?>"><?php echo ($v); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                </select>
            </td>
            <td><input type="text" name="added[<?php echo ($gad['taid']); ?>][]" id=""></td>
            <td><button type="button" onclick="add(this)" class="btn-xs btn btn-success">新增</button></td>
        </tr><?php endforeach; endif; else: echo "" ;endif; ?>
    </tbody>
</table>
<script>
    function add(obj){
        var $tr = $(obj).closest('tr').clone(true);
        var delBtn = '<button type="button" onclick="del(this)" class="btn-xs btn btn-danger">删除</button>';
        $tr.find('td:last').html(delBtn);

        $(obj).closest('tr').after($tr);
    }
    function del(obj){
        $(obj).closest('tr').remove();
    }
</script>